<?php
/*
	[gunianwang system]
	NAME:footer_model
	AUTHOR:sql
	DATE:2012-07-18
*/
if (!defined('IN_ELS'))
{
    die('Hacking attempt');
}

class footerbase extends base {
	function footerbase() {
		$this->base();
	}



		//添加入库操作
	function insertMail($data){
		$retValue = $this->dbInsert("gnw_in_mail",$data);
		return $retValue;
	}


	
	//查询数量操作
	function getCount($where){ 
		$sqlText = "select count(*) from gnw_footer ";
		$sqlText .= $where;
		$data=$this->db->result_first($sqlText);
		return $data;
	}
	//查询列表操作
	function getList($where,$limitText){
		$sqlText  = "select * from gnw_footer ";
		$sqlText .= $where;
		$sqlText .= " order by id desc ";
		$sqlText .= $limitText;
		$data=$this->db->fetch_all($sqlText);
		return $data;
	}

	// 查询footer一级
	function getone()
	{
		$sqlText  = "select * from gnw_footer where parent_id=0 ";
		$data=$this->db->fetch_all($sqlText);
		return $data;
	}
	// 修改is_ok 是否显示
	function update_is_ok($data,$where){
		$retValue = $this->dbUpdate("gnw_footer",$data,$where);
		return $retValue;
	}

	//查询会员单条数据操作
	function getmembersContent($user_id){
		$sqlText = "select * from gnw_user where id=".$user_id;
		$data=$this->db->fetch_first($sqlText);
		return $data;
	}
	
	// 查询站内信数量
	function getmailCount($where)
	{
		$sqlText = "select count(*) from gnw_in_mail ";
		$sqlText .= $where;
		$data=$this->db->result_first($sqlText);
		return $data;
	
	}
	// 查询 站内信列表
	function getmailList($where,$limitText)
	{
		$sqlText  = "select *,FROM_UNIXTIME(create_time-8*3600,'%Y-%m-%d %H:%i:%s') create_time from gnw_in_mail ";
		$sqlText .= $where;
		$sqlText .= " order by create_time desc ";
		$sqlText .= $limitText;
		$data=$this->db->fetch_all($sqlText);
		
		foreach ($data as $k=>$v)
		{
			$sql_user_name ="select user_name from gnw_user where id=".$v['u_id']." limit 1";
			$user_name=$this->db->result_first($sql_user_name);
			$data[$k]['user_name'] = $user_name;
		}
		return $data;
	}

	function updateinmail($data,$where){
		$retValue = $this->dbUpdate("gnw_in_mail",$data,$where);
		return $retValue;
	}

	

}


?>